
/*
ID: huangmingbo
LANG: JAVA
TASK: wormhole
 */

import java.io.*;
import java.util.StringTokenizer;

public class wormhole {

    public static void main(String[] args) throws IOException {
        try (
                BufferedReader reader = new BufferedReader(new InputStreamReader(wormhole.class.getResourceAsStream(wormhole.class.getSimpleName() + ".in")));
                PrintWriter writer = new PrintWriter(new FileWriter(wormhole.class.getSimpleName() + ".out"));
        ) {
            int N = Integer.parseInt(reader.readLine());
            mhole m = new mhole(N);
            StringTokenizer stringTokenizer;
            for (int i = 0; i < N; i++) {
                stringTokenizer = new StringTokenizer(reader.readLine());
                m.put(Integer.parseInt(stringTokenizer.nextToken()), Integer.parseInt(stringTokenizer.nextToken()));
            }

            writer.println(m.cal());
        }
    }

    private static class mhole {
        point[] points;
        int pointNum;

        line[] lines;

        int count;

        int resultcount;


        mhole(int N) {
            this.pointNum = 0;
            points = new point[N];
            lines = new line[N / 2];
            this.count = 0;
        }

        public void put(int x, int y) {
            points[this.pointNum++] = new point(x, y);
        }

        public int cal() {
            // find single combination
            boolean[] used = new boolean[pointNum];
            buildLine(0, used, pointNum / 2);
            return this.count;
        }

        private void buildLine(int startIndex, boolean[] used, int pairNum) {

            if (pairNum == 0) {
                increaseCount();
                return;
            }

            int start, end;
            while (used[startIndex]) {
                startIndex++;
            }

            for (int i = startIndex + 1; i < pointNum; i++) {
                if (used[i]) {
                    continue;
                }

                used[end = i] = true;
                used[start = startIndex] = true;
                lines[pairNum - 1] = new line(start, end);
                buildLine(startIndex + 1, used, pairNum - 1);
                used[end] = false;
                used[start] = false;
            }

        }

        private void increaseCount() {
            this.resultcount++;

            for (int i = 0; i < pointNum; i++) {
                byte inout = -1;
                for (int k = findnext(i, inout); k >= 0; inout *= -1, k = findnext(k, inout)) {
                    if (k == i) {
                        if ( 1 != inout) {
                            break;
                        }
                        this.count++;
                        return;
                    }
                }
            }
        }

        private int findnext(int pointIndex, byte inout) {

            if (inout == -1) {
                for (line line : lines) {
                    if (line.start == pointIndex) {
                        return line.end;
                    }

                    if (line.end == pointIndex) {
                        return line.start;
                    }

                }

                return -1;
            }

            int resultIndex = -1;
            int tmpydiff = Integer.MAX_VALUE;
            int tmp;
            for (line line : lines) {
                if ((tmp = line.start) != pointIndex && ahead(tmp, pointIndex)) {
                    if (tmpydiff > points[tmp].x - points[pointIndex].x) {
                        tmpydiff = points[tmp].x - points[pointIndex].x;
                        resultIndex = tmp;
                    }
                }

                if ((tmp = line.end) != pointIndex && ahead(tmp, pointIndex)) {
                    if (tmpydiff > points[tmp].x - points[pointIndex].x) {
                        tmpydiff = points[tmp].x - points[pointIndex].x;
                        resultIndex = tmp;
                    }
                }
            }

            return resultIndex;
        }

        private boolean ahead(int index, int index2) {
            return points[index].y == points[index2].y && points[index].x > points[index2].x;
        }

        private void printLine(line li) {
            System.out.println("(" + points[li.start].x + "," + points[li.start].y + ")," +
                    "(" + points[li.end].x + "," + points[li.end].y + ")");
        }


    }

    private static class point {
        int x, y;

        point(int x, int y) {
            this.x = x;
            this.y = y;
        }


    }

    private static class line {
        int start;
        int end;

        line(int start, int end) {
            this.start = start;
            this.end = end;
        }

    }
}
